home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / tf-texmp / texture.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1993-10-19  |  2.8 KB  |  105 lines

  1. { For a brief summary of the routine look TEXTURE.DOC }
  2. { Also for those of you who can't code Pascal ... }
  3.  
  4. PROGRAM TextureScreen;
  5. USES
  6.     Crt,MCGA;
  7. VAR
  8.    I,J,Degree,Direction:Integer;
  9.    TextSpr,BigSpr:Pointer;
  10.    ScreenX,ScreenY:Integer;
  11.  
  12. PROCEDURE PutTexture(IncX,IncY:Integer; P:Pointer);
  13. VAR
  14.    XSize,YSize,XS8,YS8:Word;
  15.    X,Y,PosX,PosY,PX,PY:Integer;
  16. BEGIN
  17.      XSize:=SpriteXSize(P);
  18.      YSize:=SpriteXSize(P);
  19.      XS8:=XSize SHL 8;
  20.      YS8:=YSize SHL 8;
  21.      PosX:=-(ScreenX SHR 1)*IncX;
  22.      PosY:=-(ScreenY SHR 1)*IncY;
  23.      FOR Y:=0 TO ScreenY-1 DO
  24.      BEGIN
  25.           PX:=PosX;
  26.           PY:=PosY;
  27.           ASM
  28.              push ds
  29.              mov ax,0a000h
  30.              mov es,ax
  31.              mov ax,y
  32.              xchg al,ah
  33.              mov di,ax
  34.              shr di,2
  35.              add di,ax
  36.              mov cx,screenx
  37.              shr cx,1
  38.              lds si,p
  39.              cld
  40.              mov ax,incx
  41.              db 66h
  42.              shl ax,16
  43.              mov ax,incy
  44.              db 66h
  45.              mov si,ax
  46.              mov dx,px
  47.              db 66h
  48.              shl dx,16
  49.              mov dx,py
  50. @1:          db 66h
  51.              add dx,si
  52.              db 66h
  53.              mov bx,dx
  54.              db 66h
  55.              shr bx,16
  56.              mov bl,dh
  57.              mov al,[bx]
  58.              db 66h
  59.              add dx,si
  60.              db 66h
  61.              mov bx,dx
  62.              db 66h
  63.              shr bx,16
  64.              mov bl,dh
  65.              mov ah,[bx]
  66.              stosw
  67.              dec cx
  68.              jnz @1
  69.              pop ds
  70.           END;
  71.           Inc(PosX,IncY);
  72.           Inc(PosY,-IncX);
  73.      END;
  74. END;
  75.  
  76. BEGIN
  77.      Write('X-Size of screen=');
  78.      ReadLn(ScreenX);
  79.      Write('Y-Size of screen=');
  80.      ReadLn(ScreenY);
  81.      MCGAOn;
  82.      LoadPalette('KEWLAARD');
  83.      LoadSprite('KEWLAARD',TextSpr);
  84.      GetMem(BigSpr,65535);   { BigSpr -> Pointer to 64k Array [255][255] }
  85.      IF Ofs(BigSpr)<>0 THEN
  86.         BigSpr:=Ptr(Seg(BigSpr^)+1,0);
  87.      FOR J:=0 TO 199 DO
  88.          FOR I:=0 TO 255 DO
  89.              Mem[Seg(BigSpr^):Word(J) SHL 8+I]:=Mem[Seg(TextSpr^):4+Word(J)*320+I];
  90.      FillChar(Ptr(Seg(BigSpr^),51200)^,14336,0);
  91.      Degree:=0;   { Degree is used for both rotating and zooming values! }
  92.      Direction:=1;
  93.      REPEAT
  94.            VerticalRetrace;
  95.            PutTexture(Round(4*Degree*Sin(Degree/180*Pi)),Round(4*Degree*Cos(Degree/180*Pi)),BigSpr);
  96.            Inc(Degree,Direction);
  97.            IF (Degree=0) OR (Degree=360) THEN
  98.               Direction:=-Direction;
  99.      UNTIL KeyPressed;
  100.      MCGAOff;
  101. END.
  102.  
  103. { It's floating point Sin and Cosine calculations, call it lame, but I don't
  104.   want to spend 5 minutes to make this 0.5% faster =)                    }
  105.